<template>
  <div>
    <div class="comment-module" v-for="(item,index) in Posts" :key="index" ﻿@tap="toDetail(item.id, item.status,item.auth)">
      <item :isAdd="isAdd" :needStatus="needStatus" :item ="item" :delBtn="delBtn" :jurisdiction="jurisdiction" @delPosts="deleteBtn"></item>
    </div>
  </div>
</template>

<script>
  import item from '@/components/comment/item'
  import { mapState } from 'vuex'
    export default {
        name: "index",
      components: {
        item
      },
      props:{
        Posts:{
          type:Array
        },
        delBtn:{
          type: Boolean,
          default:false
        },
        //需要去判断该发帖的审核成功没
        needStatus:{
          type: Boolean,
          default:false
        },
        jurisdiction:{
          type: Boolean,
          default: false
        },
        // 是否加入群组
        isAdd:{
          type: String,
          default: 'no'
        }
      },
      data(){
          let that = this;
        return {
          picPre: that.$api.picPre,
            comment: 'comment',
            notComment: 'notComment'
          }
      },
      methods:{
        toDetail(id,status,auth){
          console.log(id,status,auth)
          if(!this.isLogin){
            let that = this;
            ﻿uni.showModal({
              title: '亲，您尚未登录',
              content: '前去登录吧~',
              success (res) {
                if (res.confirm) {
                  ﻿uni.navigateTo({ 				  	
					  url:'/person/login' 				  ,
					  })
                }
              }
            });
          }
          else {
            if(this.needStatus){
              if(status === "3"){
				  uni.navigateTo({
				  	url: '/movie/postDetails?id='+id
				  })
              } else if(status === "1") {
                ﻿uni.showToast({
                  title: '该帖子待审核',
                  icon: 'none',
                  duration: 2000
                })
              } else if(status === "2") {
                ﻿uni.showToast({
                  title: '该帖子未通过审核',
                  icon: 'none',
                  duration: 2000
                })
              }
            }
            else if(this.jurisdiction){
              if(auth === "yes"){
				  uni.navigateTo({
				  	url: '/movie/postDetails?id='+id
				  })
              }
              else {
                ﻿uni.showToast({
                  title: '未加入此群组，暂无权查看！',
                  icon: 'none',
                  duration: 2000
                })
              }
            }
            else {
				uni.navigateTo({
					url: '/movie/postDetails?id='+id
				})
            }
          }
        },
        deleteBtn(id){
          this.$emit('delPosts', id);
        },
      },
      computed: {
        ...mapState([
          'isLogin'
        ])
      },
    }
</script>

<style scoped>
.comment-module{
  padding: 30rpx 30rpx 0 22rpx;
}

</style>
